﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Web.UI.WebControls;
using System.Data;

namespace ChinaSoft.Common
{
    public class BindControl
    {
        /// <summary>
        /// 绑定下拉框
        /// 作者：卢亚东
        /// 时间：2011-7-19
        /// </summary>
        /// <param name="ddl">下拉框名称</param>
        /// <param name="ds">数据源</param>
        /// <param name="dataTextFiled">要在前台显示的文本内容</param>
        /// <param name="dataValueFiled">要在后台显示的值的内容</param>
        public static void BindDropDownList(DropDownList ddl, DataSet ds, string dataTextFiled, string dataValueFiled)
        {
            if (ds != null)
            {
                ddl.DataSource = ds;
                ddl.DataTextField = dataTextFiled;
                ddl.DataValueField = dataValueFiled;
                ddl.DataBind();
                ddl.Items.Insert(0, "");
            }
        }
    }
}
